const router = require("koa-router")()

// var music = require("../controllers/music")
var detail = require("../controllers/detail")
var search = require("../controllers/search")

router.get("/music",async ctx=>{
    // let data = await music()
    ctx.body = {
        code:200,
        msg:"网易云音乐首页数据",
        result:require("../data/data")
    }
})
router.get("/detail/:id",async ctx=>{
    var {id} = ctx.request.params
    let data = await detail(id)
    ctx.body={
        code:200,
        msg:"网易云音乐详情页数据",
        result:data
    }
})
router.get("/search",async ctx=>{
    var {keyword} = ctx.query
    keyword = encodeURIComponent(keyword)
    let data = await search(keyword)
    ctx.body={
        code:200,
        msg:"网易云音乐搜索页数据",
        result:data
    }
})
module.exports = router